package thread.state;


import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author 真香
 * @create 2021-06-03 21:17
 */
public class TestSleep2 {

    public static void main(String[] args) throws InterruptedException {

        // 打印系统当前时间
        Date dateTime = new Date(System.currentTimeMillis());

        while (true) {

            Thread.sleep(1000);
            System.out.println(new SimpleDateFormat("HH:mm:ss").format(dateTime));
            // 更新为当前最新时间
            dateTime= new Date(System.currentTimeMillis());


        }


    }


    // 倒计时
    private static void countDown() throws InterruptedException {
        int num =10;

        while (true) {
            Thread.sleep(1000);
            System.out.println(num--);

            if (num < 0) {
                break;
            }

        }
    }

}
